package com.opal.system.controller;

import com.opal.system.entity.ClockInQueryForm;
import com.opal.system.entity.table.OrgHrorg;
import com.opal.system.entity.table.TbmImportData;
import com.opal.system.service.HRService;
import com.opal.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * HR相关功能
 */
@Controller
@RequestMapping("/hr")
public class HrController {

    @Autowired
    private HRService hrService;

    /**
     * 获取组织名称
     * @return
     */
//    @RequestMapping("/OrgHrorg")
//    @ResponseBody
//    public List<OrgHrorg> OrgHrorg() {
//
//        return hrService.orgHrorgFindAll();
//    }

    /**
     * 判断是否已封存 无封存执行清除重复卡
     * @param orgHrorg
     * @return
     */
    @RequestMapping("/sealflag")
    @ResponseBody
    public Map sealflag(OrgHrorg orgHrorg) {

        Map result = hrService.finBySealflag(orgHrorg);
        return result;
    }


    /**
     * 打卡信息-删除原始打卡时间
     * @param clockInQueryForm
     * @return
     */
    @RequestMapping("/clockInInfo")
    @ResponseBody
    public PageVO<TbmImportData> ClockInInfo(ClockInQueryForm clockInQueryForm, @RequestParam("page") int page, @RequestParam("rows") int rows){
        return hrService.findByClockInInfo(clockInQueryForm,page,rows);
    }


    /**
     * 删除打卡信息-删除原始打卡时间
     * @param id
     * @param userName
     * @return
     */
    @RequestMapping("/delectClockInInfo")
    @ResponseBody
    public Map delectClockInInfo(@RequestParam("pkImportdataId[]") List<String> id,@RequestParam("name")String userName){
        return hrService.delectClockInInfo(id,userName);
    }

    @RequestMapping("{page}")
    public String skipPage(@PathVariable("page") String page) {
        return "hr/" + page;
    }
}
